home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.gu.edu.au!usenet
- From: Student (Student)
- Newsgroups: comp.lang.c
- Subject: Re: A real basic problem?: (code!) long integers or compiler problem?
- Date: 19 Apr 1996 06:12:30 GMT
- Organization: Griffith University
- Message-ID: <4l7ase$r44@griffin.itc.gu.edu.au>
- References: <4l3mom$f26@newsbf02.news.aol.com> <4l699u$cgo@newsbf02.news.aol.com>
- NNTP-Posting-Host: enslab29.student.gu.edu.au
- X-Newsreader: WinVN 0.92.5
-
-
- This is a tidied up version of your original.
- Try it out - it has some small but significant changes.
- I haven't compiled it myself - so I don't know if it works
- but it should not hang.
- The negative values you talked about would be because of %d
-
-
- #include <stdio.h>
- //#include "local.h" why do this???
-
- long maxlng(void);
-
- main(void){
- long i;
- i=maxlng();
- printf("max i= %ld, max i+1= %ld",i,i+1);
- }
-
- maxlng(void){
- long first, b;
- first= 10000;
- while (first >= 0){
- b= first;
- printf("b= %ld, first= %ld\n",b, first);
- first++;
- }
- // why not put the printf here instead of in main?
- // it would avoid some confusing data name changes
- return (b);
- }
-
-
-
- >
- >Whether I change the %d to %ld, does not make any difference. If I put
- >some printf statements in my loop, "first" is negative (!) sometimes
- >during this loop even though the "while" statement is only supposed to
- >work if "first" is positive!
- >
- >Thanks once again!
- >
-